/**
 * Created by meiguizhinian on 2018/7/4
 * Copyright © 2018 lixiaolong. All rights reserved.
 */

//对象 let obj = new ll.Obj(param)
(function () {
	ivy.Delegate = function () {
		//成员变量
		this._mapDelegate = new LLDictionary();
	};
	let p = ivy.Delegate.prototype;

	p.empty = function () {
		return this._mapDelegate.empty();
	};
	p.clear = function () {
		this._mapDelegate.clear();
	};
	p.add = function(fun, tag=ivy.Delegate.DefaultDelegateTAG) {
		if (!this._mapDelegate.has(tag)) {
			this._mapDelegate.set(tag, []);
		}
		this._mapDelegate.get(tag).push(fun);
	};
	p.sub = function (tag) {
		this._mapDelegate.set(tag, []);
	};
	p.call = function (...args) {
		for (let value of this._mapDelegate.values()) {
			for (let v of value) {
				v(...args);
			}
		}
	}
})();

ivy.Delegate.DefaultDelegateTAG = 0;